<template>
  <div class="notself">
    <Form ref="formInline" :model="formInline" >
      <FormItem prop='apprno' :rules="validator.int" :maxlength="7">
        <Input type="text" v-model="formInline.apprno" placeholder="名称文号中7位编号" class="notself_number"></Input>
      </FormItem>
      <FormItem prop='cerno' :rules="validator.cerno" :maxlength="18">
        <Input type="text" v-model="formInline.cerno" placeholder="名称申请人证件号码" class="notself_id"></Input>
      </FormItem>
      <div class="notself_apply">
        <Button type="primary" long @click="startBusiness()">进入办理</Button>
      </div>
    </Form>
    <div class="notself_bottom">
      <MyFooter />
    </div>
  </div>
</template>

<script>
  import MyFooter from '../../components/MyFooter.vue'
  import request from '../../utils/request'
  import validator from '../../utils/validatorUtil.js'
  export default {
    data() {
      return {
        validator,
        formInline: {
          apprno: '',
          cerno: ''
        }
      }
    },
    methods: {
      startBusiness() {
        this.$refs['formInline'].validate((valid) => {
          if (valid) {
            request.get('/interface/apply/cp/setup/startBusiness.do', {
                apprno: this.formInline.apprno,
                cerno: this.formInline.cerno,
                regorg: localStorage.getItem('regorg')
              }
            ).then(response => {
              if (response.data.result === 'error') {
                this.$ErrorAlert(response.data.message)
                return null
              }
              // 成功逻辑
              this.gid = response.data.data.gid
              sessionStorage.setItem('gid', response.data.data.gid)
              sessionStorage.setItem('pripid', response.data.data.pripid)
              sessionStorage.setItem('username', response.data.data.username)
              this.$router.push({name: 'ApplyModule'})
            })
          }
        })
      }
    },
    components: {
      MyFooter
    }
  }

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
  .notself {
    position: relative;
    min-height: 100%;
    padding-bottom: 2.25rem;
    background: #f3f3f3;
    .ivu-form-item {
      margin: 0;
    }
    input {
      height: 1.75rem;
      font-size: 0.57rem;
      border: none;
      border-bottom: 1px solid #dedede;
      border-radius: 0;
      &:hover {
        border: none;
        border-bottom: 1px solid #dedede;
      }
      &:focus {
        border: none;
        border-bottom: 1px solid #dedede;
        box-shadow: none;
      }
    }
    &_apply {
      margin: 0.54rem;
      button {
        font-size: 0.57rem;
      }
    }
    &_bottom {
      position: absolute;
      bottom: 0;
      width: 100%;
    }
  }

</style>
